package com.zyb.insurance.common;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisClient {

    private JedisPool jedisPool;

    private RedisClient() {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(200);
        config.setMaxTotal(300);
        config.setTestOnBorrow(false);
        config.setTestOnReturn(false);

//        this.jedisPool = new JedisPool(config,
//                "192.168.21.177",
//                6379, 3000, "Ruyuan2020");
        this.jedisPool = new JedisPool(config,
                "192.168.21.177",
                6379, 3000);
    }

    public Jedis getJedis() {
        return jedisPool.getResource();
    }

    private static class Singleton {
        static RedisClient instance = new RedisClient();
    }

    public static RedisClient getInstance() {
        return Singleton.instance;
    }

}
